gtkwindow: default size with fixed size windows
authorOlivier Fourdan <ofourdan@redhat.com>
Fri, 4 Mar 2016 20:29:25 +0000 (21:29 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 5 Mar 2016 01:17:50 +0000 (20:17 -0500)
Allow fixed size windows with a default size to grow or shrink as the
content requires, but not smaller than the given default size.

https://bugzilla.gnome.org/show_bug.cgi?id=762974

gtk/gtkwindow.c

index 563414db434c50e8e2392e6c9381de858d2dc9bb..f5cf1baf8fb1266a137338c224841998f64965b5 100644 (file)
@@ -9001,9 +9001,6 @@ gtk_window_compute_configure_request_size (GtkWindow   *window,
   *height = MAX (*height, 1);
 }
 
-#undef INCLUDE_CSD_SIZE
-#undef EXCLUDE_CSD_SIZE
-
 static GtkWindowPosition
 get_effective_position (GtkWindow *window)
 {
@@ -9774,7 +9771,7 @@ gtk_window_constrain_size (GtkWindow   *window,
  * width/height if set, but can still grow if their content requires.
  *
  * Note: Fixed size windows with a default size set will not shrink
- * when their content requires less size.
+ * smaller than the default size when their content requires less size.
  */
 static void
 gtk_window_update_fixed_size (GtkWindow   *window,
@@ -9783,25 +9780,33 @@ gtk_window_update_fixed_size (GtkWindow   *window,
                               gint         new_height)
 {
   GtkWindowPrivate *priv = window->priv;
-  gint default_width;
-  gint default_height;
+  GtkWindowGeometryInfo *info;
 
   /* Adjust the geometry hints for non-resizable windows only */
   if (priv->resizable)
     return;
 
-  /* if a default size is set, make sure the hints allow for the new size */
-  gtk_window_get_default_size (window, &default_width, &default_height);
-  if (default_width > -1)
+  info = gtk_window_get_geometry_info (window, FALSE);
+  if (info)
     {
-      new_geometry->min_width = MAX (new_width, new_geometry->min_width);
-      new_geometry->max_width = new_geometry->min_width;
-    }
+      gint default_width_csd = info->default_width;
+      gint default_height_csd = info->default_height;
 
-  if (default_height > -1)
-    {
-      new_geometry->min_height = MAX (new_height, new_geometry->min_height);
-      new_geometry->max_height = new_geometry->min_height;
+      gtk_window_update_csd_size (window,
+                                  &default_width_csd, &default_height_csd,
+                                  INCLUDE_CSD_SIZE);
+
+      if (info->default_width > -1)
+        {
+          new_geometry->min_width = MAX (default_width_csd, new_width);
+          new_geometry->max_width = new_geometry->min_width;
+        }
+
+      if (info->default_height > -1)
+        {
+          new_geometry->min_height = MAX (default_height_csd, new_height);
+          new_geometry->max_height = new_geometry->min_height;
+        }
     }
 }
 
@@ -9916,6 +9921,9 @@ gtk_window_compute_hints (GtkWindow   *window,
   new_geometry->win_gravity = priv->gravity;
 }
 
+#undef INCLUDE_CSD_SIZE
+#undef EXCLUDE_CSD_SIZE
+
 /***********************
  * Redrawing functions *
  ***********************/